package com.apache.portal.common.oscache;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class OsCacheOtherManager {

    private ConcurrentMap<String, BaseOsCache> caches = new ConcurrentHashMap<String, BaseOsCache>();

    private static OsCacheOtherManager instance;

    private final String key_prefix = "other_";

    private OsCacheOtherManager() {
    }

    public static synchronized OsCacheOtherManager getInstance() {
        if (instance == null) {
            instance = new OsCacheOtherManager();
        }
        return instance;
    }

    public BaseOsCache getBaseOsCache(String key, int refreshPeriod) {
        BaseOsCache cache = caches.get(key_prefix + key);
        if (null == cache) {
            cache = new BaseOsCache(key_prefix + key, refreshPeriod);
            caches.put(key_prefix + key, cache);
        }
        return cache;
    }
}
